Bug 5447

Bug Description:

This is a deadlock.
The following is an example of deadlock thread dump:

"Thread-2": waiting to lock monitor 0x000000000d1322b8 (object 0x00000007d6635cc8, 
a org.apache.derby.impl.store.raw.data.StoredPage), which is held by "Thread-1"
"Thread-1": waiting to lock monitor 0x000000000ae0f818 (object 0x00000007d6593af0,
a org.apache.derby.impl.store.raw.data.BaseContainerHandle), which is held by "Thread-2"

Java stack information for the threads listed above:
===================================================
"Thread-2":
at org.apache.derby.impl.store.raw.data.BasePage.isLatched(BasePage.java:1313)
- waiting to lock <0x00000007d6635cc8> (a org.apache.derby.impl.store.raw.data.StoredPage)

at org.apache.derby.impl.store.raw.data.BasePage.update(BasePage.java:1545)
at java.util.Observable.notifyObservers(Observable.java:159)
at java.util.Observable.notifyObservers(Observable.java:115)
at org.apache.derby.impl.store.raw.data.BaseContainerHandle.informObservers(BaseContainerHandle.java:1008)
at org.apache.derby.impl.store.raw.data.BaseContainerHandle.close(BaseContainerHandle.java:414)
- locked <0x00000007d6593af0> (a org.apache.derby.impl.store.raw.data.BaseContainerHandle)
at org.apache.derby.impl.store.raw.data.Derby5447$Thread2.run(Derby5447.java:59)
"Thread-1":
at java.util.Observable.deleteObserver(Observable.java:95)
- waiting to lock <0x00000007d6593af0> (a org.apache.derby.impl.store.raw.data.BaseContainerHandle)
at org.apache.derby.impl.store.raw.data.BasePage.releaseExclusive(BasePage.java:1740)
- locked <0x00000007d6635cc8> (a org.apache.derby.impl.store.raw.data.StoredPage)

at org.apache.derby.impl.store.raw.data.CachedPage.releaseExclusive(CachedPage.java:528)
at org.apache.derby.impl.store.raw.data.StoredPage.releaseExclusive(StoredPage.java:1093)
at org.apache.derby.impl.store.raw.data.Derby5447$Thread1.run(Derby5447.java:47)
More details about this bug are at DERBY-5447 JIRA page.

How To Reproduce:

This bug is reproduced under derby 10.5.1.1 and JDK 1.6.0_33.
Execute the following scripts to run the test to reproduce the bug (assume the location of the derby test project is derby_test_home).

Linux:
${derby_test_home}/scripts/5447.sh [--monitoroff]
Windows:
%derby_test_home%\scripts\5447.bat [--monitoroff]

p>

Example: Use monitor to report and terminate the program when deadlock happens:
${derby_test_home}/scripts/5447.sh


Turn off monitor:
${derby_test_home}/scripts/5447.sh --monitoroff

Option Function
--monitoroff, -mo Turn off to stop reporting bug messages and ending program when test
runs into the expected concurrency bug which is a deadlock.
User has to terminate the program manually when this option is set.